package com.example.stumanager.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.stumanager.R;
import com.example.stumanager.entity.RepairEntity;

import java.util.ArrayList;

/**
 * 报修适配器
 */
public class RepairAdapter extends ArrayAdapter<RepairEntity> {
    public RepairAdapter(@NonNull Context context, int resource, @NonNull ArrayList objects) {
        super(context, resource, objects);
    }
    //每个子项被滚动到屏幕内的时候会被调用
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        RepairEntity w=getItem(position);
        View view= LayoutInflater.from(getContext()).inflate(R.layout.layout_baoxiu,parent,false);
        TextView address =view.findViewById(R.id.address);
        TextView name =view.findViewById(R.id.name);
        TextView tel =view.findViewById(R.id.tel);
        TextView content =view.findViewById(R.id.content);
        address.setText("地址："+w.getAddress());
        tel.setText("电话："+w.getTel());
        name.setText("报修人："+w.getName());
        content.setText("内容："+w.getContent());

        return view;
    }

}
